import {useState,lazy,useRef} from 'react'
const Child = lazy(()=>import('./child'))
const Parent = ()=>{
    const childRef = useRef<any>(null)
    const [title,setTitle] = useState<string>('标题')
    const [name,setName] = useState<string>('李四')
    const changeTitle = (data:string)=>{
        setTitle(data)
    }
    const change = ()=>{
        childRef?.current?.handleName()
    }
    return(
        <>
        <Child ref={childRef} title={title} name={name} changeTitle={changeTitle} />
        <button onClick={change}> 主动修改</button>
        </>
    )
}